<template>
  <div class="container">
    <van-nav-bar
      fixed
      title="登录"
      @click-left="$router.back()"
      left-arrow
    />

    <div class="logo-txt">
      优点达资讯
    </div>
    <van-form
      @submit="onSubmit"
      label-width="50px"
    >
      <van-field
        v-model="mobile"
        name="mobile"
        label="用户名"
        placeholder="请输入手机号"
        left-icon="manager"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        label="密码"
        placeholder="密码"
        left-icon="lock"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px">
        <van-button
          round
          block
          type="info"
          native-type="submit"
        >提交</van-button>
      </div>
    </van-form>
    <van-row
      type="flex"
      justify="end"
    >
      <van-col :span="10">
        <router-link to="/reg">没有账号,立即注册</router-link>
      </van-col>
    </van-row>
  </div>
</template>

<script>

export default {

  data () {
    return {
      mobile: '',
      password: '',
      flag: true
    }
  },
  methods: {
    onSubmit (values) {
      // console.log('submit', values)
      this.$store.dispatch('Login/getlogin', values)

      // if (res.errno === 0) {
      //   this.$toast.success('登录成功')
      //   settoken(res.data.token)
      //   this.$router.push(`/user?flag=true`)
      //   // this.$router.push({
      //   //   path: '/user',
      //   //   query: {
      //   //     flag: true,
      //   //   }
      //   // })
      // } else {
      //   this.$toast.fail(res.errmsg)
      // }
    },
  },
}
</script>

<style scoped>
.logo-txt {
  text-align: center;
  font-size: 60px;
  margin: 60px auto;
  color: #1989fa;
}
</style>
